package com.xysl.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.xysl.api.domain.Advertisement;
import com.xysl.api.domain.XyslMenu;
import com.xysl.api.domain.XyslUser;
import com.xysl.api.model.XyslLoginUser;
import com.xysl.domain.dto.AdvertisementDTO;
import com.xysl.domain.dto.XyslMenuDTO;
import com.xysl.domain.vo.HomePageResVo;
import com.xysl.service.AdvertisementService;
import com.xysl.service.IXyslHomeService;
import com.xysl.service.IXyslPermissionService;
import com.xysl.service.IXyslUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

/**
 * xysl首页Controller
 *
 * @author xysl
 * @date 2024-12-27
 */
@Tag(name = "xysl_App首页",description ="xysl_App首页")
@RestController
@RequestMapping("/home")
    public class XyslHomeController extends BaseController
{
    @Resource
    private IXyslHomeService xyslHomeService;

    @Resource
    private IXyslUserService userService;

    @Resource
    private AdvertisementService advertisementService;

    @Autowired
    private IXyslPermissionService permissionService;
    /**
     * 获取当前登录用户菜单
     *
     */
    @Operation(summary = "首页展示信息")
    @PostMapping("/information")
    public R<HomePageResVo> info()
    {
        HomePageResVo result = new HomePageResVo();
        XyslLoginUser xyslLoginUser = SecurityUtils.getXyslLoginUser();
        //菜单列表
        XyslMenuDTO menuDTO = new XyslMenuDTO();
        menuDTO.setUserId(xyslLoginUser.getXyslUser().getId());
        List<XyslMenu> menuList = userService.queryLoginUserMenuList(menuDTO);
        result.setMenuList(menuList);
        //广告列表
        AdvertisementDTO advParam = new AdvertisementDTO();
        List<Advertisement> advList = advertisementService.queryAdvList(advParam);
        result.setAdvList(advList);
        return R.ok(result);
    }



}
